package cn.itcast.quartz.demo4;

import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

import cn.itcast.quartz.demo2.HelloJob;

public class Demo4 {
	public static void main(String[] args) throws SchedulerException {
		SchedulerFactory sf = new StdSchedulerFactory();
		Scheduler scheduler = sf.getScheduler();

		JobDetail job = JobBuilder.newJob(HelloJob.class).withIdentity("job1", "group1").build();

		Trigger trigger = TriggerBuilder.newTrigger().forJob("job1", "group1").startNow()
				.withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(22, 52)).build();

		scheduler.scheduleJob(job, trigger);

		scheduler.start();
	}
}
